/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ControlLager;
import ModelLager.*;
import DBLager.*;
import java.util.ArrayList;
/**
 *
 * @author Ronni
 */
public class ProductPCTR{

    private IFDbProductP pInterface;
    
    public ProductPCTR() {
    ///////////////////////////////////////////////////////////////////////////    
    ///////////////////////////////////////////////////////////////////////////    
        pInterface = new DbProductP();/////////////////////////////////////////
    ///////////////SPØRG KIS OM DET HER////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////
    }
    
    public ProductP findProduct(int productID)
    {
        return pInterface.findProduct(productID);
    }
    public ArrayList<ProductP> findProducts(String name)
    {
        return pInterface.findProducts(name);
    }
    public int createProduct(String name, double purchasePrice, double salesPrice, double rentPrice, String countryOfOrigin, int minStock, int barCode, int productID, int supplierID, String type, String description, String size, String color, String fabric, String descriptionGun)
    {
        //lav produktet udfra variabler, indsæt så(dobbletkonfekt)
            ProductP proObj = new ProductP(name, purchasePrice,salesPrice, rentPrice, countryOfOrigin, minStock, barCode, productID,supplierID, type, description, size, color, fabric, descriptionGun);     
            proObj.setName(name);
            proObj.setPurchasePrice(purchasePrice);
            proObj.setSalesPrice(salesPrice);
            proObj.setRentPrice(rentPrice);
            proObj.setCountryOfOrigin(countryOfOrigin);
            proObj.setMinStock(minStock);
            proObj.setBarCode(barCode);
            proObj.setProductID(productID);
            proObj.setSupplierID(supplierID);
            proObj.setType(type);
            proObj.setDescription(descriptionGun);
            proObj.setSize(size);
            proObj.setColor(color);
            proObj.setFabric(fabric);
            proObj.setDescriptionGun(descriptionGun);
        return pInterface.insertProduct(proObj);        
    }
    public int updateProduct(String name, double purchasePrice, double salesPrice, double rentPrice, String countryOfOrigin, int minStock, int barCode, int productID, int supplierID, String type, String description, String size, String color, String fabric, String descriptionGun)
    {
            ProductP proObj = pInterface.findProduct(productID);
            proObj.setName(name);
            proObj.setPurchasePrice(purchasePrice);
            proObj.setSalesPrice(salesPrice);
            proObj.setRentPrice(rentPrice);
            proObj.setCountryOfOrigin(countryOfOrigin);
            proObj.setMinStock(minStock);
            proObj.setBarCode(barCode);
            proObj.setProductID(productID);
            proObj.setSupplierID(supplierID);
            proObj.setType(type);
            proObj.setDescription(descriptionGun);
            proObj.setSize(size);
            proObj.setColor(color);
            proObj.setFabric(fabric);
            proObj.setDescriptionGun(descriptionGun);
            return pInterface.updateProduct(proObj);
            
    }
    public int deleteProduct(ProductP product)
    {
        return pInterface.deleteProduct(product);
    }
    
}
